﻿<UserControl x:Class="YouTubePlaylist.Views.FinderCtrl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    xmlns:Ctrls="clr-namespace:Radovici.Ctrls;assembly=RadoviciCtrls"
    xmlns:stepi="clr-namespace:Stepi.UIFilters;assembly=Stepi.UIFilters"
    xmlns:SharedLibrary="clr-namespace:Radovici.SharedLibrary;assembly=RadoviciSharedLibrary"
    xmlns:Views="clr-namespace:YouTubePlaylist.Views"
    xmlns:Data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:ContentControls="clr-namespace:Radovici.Ctrls.ContentControls;assembly=RadoviciCtrls"
    xmlns:Hacks="clr-namespace:Radovici.Ctrls.Hacks;assembly=RadoviciCtrls">
    <UserControl.Resources>
        <SharedLibrary:BooleanToVisibilityConverter x:Key="ToVisibilityConverter" />        
        <Style TargetType="Primitives:DataGridColumnHeader" x:Key="columnHeaderStyle" >
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid Height="{TemplateBinding Height}" Width="Auto">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <TextBlock Text="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0.2"/>
                                <!-- InitalizersManager="{StaticResource filtersViewInitializersManager}" if you want a different initializers list-->
                                <stepi:DataGridColumnFilter Background="Transparent" Width="Auto" Height="Auto" Margin="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,2,0,2">
            <TextBlock Text="Search:" Margin="0,0,2,0" VerticalAlignment="Center"/>
            <TextBox x:Name="SearchString" MinWidth="200" VerticalAlignment="Center" TextChanged="OnSearchChanged"/>
        </StackPanel>
        <Hacks:DataGridPlus Grid.Row="1" ItemsSource="{Binding PlaylistsView}" ColumnHeaderStyle="{StaticResource columnHeaderStyle}" IsReadOnly="True" AutoGenerateColumns="false"
                            MouseLeftButtonUp="OnMouseLeftButtonUp" MouseDoubleClicked="OnDoubleClicked"
                            Margin="2">
            <Data:DataGrid.Columns>
                <Data:DataGridTemplateColumn Header="Name">
                    <Data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ContentControls:Dropable>
                                <TextBlock Text="{Binding Name}"/>
                            </ContentControls:Dropable>
                        </DataTemplate>
                    </Data:DataGridTemplateColumn.CellTemplate>
                </Data:DataGridTemplateColumn>
                <Data:DataGridTextColumn Header="Tracks" Binding="{Binding Tracks.Count}"/>
            </Data:DataGrid.Columns>
        </Hacks:DataGridPlus>
        <Hacks:DataGridPlus Grid.Row="2" ItemsSource="{Binding UserTracksView}" ColumnHeaderStyle="{StaticResource columnHeaderStyle}" IsReadOnly="True" AutoGenerateColumns="false"
                            MouseLeftButtonUp="OnMouseLeftButtonUp" MouseDoubleClicked="OnDoubleClicked"
                            Margin="2">
            <Hacks:DataGridPlus.Columns>
                <Data:DataGridTextColumn Header="Artist" Binding="{Binding Artist}"/>
                <Data:DataGridTemplateColumn Header="Title">
                    <Data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ContentControls:Dropable VerticalAlignment="Center">
                                <TextBlock Text="{Binding Name}"/>
                            </ContentControls:Dropable>
                        </DataTemplate>
                    </Data:DataGridTemplateColumn.CellTemplate>
                </Data:DataGridTemplateColumn>
            </Hacks:DataGridPlus.Columns>
        </Hacks:DataGridPlus>
        <Hacks:DataGridPlus Grid.Row="3" ItemsSource="{Binding TracksView}" ColumnHeaderStyle="{StaticResource columnHeaderStyle}" IsReadOnly="True" AutoGenerateColumns="false"
                            MouseLeftButtonUp="OnMouseLeftButtonUp" MouseDoubleClicked="OnDoubleClicked"
                            Margin="2">
            <Hacks:DataGridPlus.Columns>
                <Data:DataGridTextColumn Header="Artist" Binding="{Binding Artist}"/>
                <Data:DataGridTemplateColumn Header="Title">
                    <Data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ContentControls:Dropable VerticalAlignment="Center">
                                <TextBlock Text="{Binding Name}"/>
                            </ContentControls:Dropable>
                        </DataTemplate>
                    </Data:DataGridTemplateColumn.CellTemplate>
                </Data:DataGridTemplateColumn>
                <Data:DataGridTextColumn Header="Genre" Binding="{Binding Genre}"/>
                <Data:DataGridTextColumn Header="Year" Binding="{Binding Year}"/>
                <Data:DataGridTextColumn Header="Rank" Binding="{Binding NumInstances}"/>
            </Hacks:DataGridPlus.Columns>
        </Hacks:DataGridPlus>
        <Grid Grid.Row="4" Margin="0,2,0,2">
            <ProgressBar IsIndeterminate="{Binding IsCalculating}"/>
            <TextBlock Text="{Binding Status}" VerticalAlignment="Center" Margin="4,0,0,0"/>
        </Grid>
    </Grid>
</UserControl>
